<?php defined('SYSPATH') or die('No direct script access.');

class Recomment_Controller extends  Template_Controller {
	// Disable this controller when Kohana is set to production mode.
	// See http://docs.kohanaphp.com/installation/deployment for more details.
	const ALLOW_PRODUCTION = FALSE;

	// Set the name of the template to use
	public $template = 'layouts/template_hongshaw_other';


	public function index(){
		$this->template->content = new View('recomment');
		$this->template->content->categorys=ORM::factory("category")->find_all();
		$this->template->content->contact_types=ORM::factory("contact_type")->find_all();
		$this->template->content->captcha = Captcha::factory();
		$this->template->content->send_data = "N";
		//$d=getdate();
		//$date = $d['year'].'-'.$d['month'].'-'.$d['mday'].' '.$d['hours'].':'.$d['minutes'].':00';
		//$format = 'Y-m-d H:i:s';
 		//echo DateTime::createFromFormat($format, '20111011');
		// An array of links to display. Assiging variables to views is completely
		// asyncronous. Variables can be set in any order, and can be any type
		// of data, including objects.
		$this->template->content->links = array
		(
			'Home Page'     => 'http://kohanaphp.com/',
			'Documentation' => 'http://docs.kohanaphp.com/',
			'Forum'         => 'http://forum.kohanaphp.com/',
			'License'       => 'Kohana License.html',
			'Donate'        => 'http://kohanaphp.com/donate',
		);
		//$this->template->content->render(true);
	}

	public function insert(){
		$this->template->content = new View('recomment');
		$this->template->content->categorys=ORM::factory("category")->find_all();

		if ($_POST && Captcha::valid($this->input->post('captcha_response'))){
			$recomment = new Contact_Model();
			$recomment->title=$this->input->post("title");
			$recomment->full_name =$this->input->post("full_name");
			$recomment->description=$this->input->post("description");
			$recomment->email=$this->input->post("email");
			$recomment->send_date=NULL;
			$recomment->contact_type_id=1;
			$contact->save();
			$this->template->content->send_data = "Y";
		}

		$this->template->content->captcha = Captcha::factory();
		// An array of links to display. Assiging variables to views is completely
		// asyncronous. Variables can be set in any order, and can be any type
		// of data, including objects.
		$this->template->content->links = array(
			'Home Page'     => 'http://kohanaphp.com/',
			'Documentation' => 'http://docs.kohanaphp.com/',
			'Forum'         => 'http://forum.kohanaphp.com/',
			'License'       => 'Kohana License.html',
			'Donate'        => 'http://kohanaphp.com/donate',
		);
	}


}
